package com.liang.respository;

import com.liang.entity.GoodsStore;
import io.lettuce.core.dynamic.annotation.Param;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import javax.transaction.Transactional;

/**
 * Created with Intellij IDEA
 *
 * @Auther: liangjy
 * @Date: 2022/01/07/11:48
 * @Description:
 */

public interface GoodsStoreRespository extends JpaRepository<GoodsStore,String> {
    /**
     * 更新库存
     * @param code
     * @param store
     * @return
     */
    @Modifying
    @Transactional
    @Query("update GoodsStore gs set gs.store=gs.store-?2 where gs.code=?1")
    int updateStore(@Param("code") String code, @Param("store")Integer store);
}
